import { ref } from 'vue'
import { updateWarrantyCategoryStatusByIds } from '@/api/order'

/**
 * 启用
 */
export const useEnableWarrantyCategory = () => {
  // 启用加载
  const enableLoading = ref(false)

  /**
   * 启用
   * @param ids - 质保类别id集合
   */
  const enable = async (ids: Array<string>) => {
    enableLoading.value = true
    const res = await updateWarrantyCategoryStatusByIds(ids, false)
    enableLoading.value = false
    return res.data
  }

  return {
    enableLoading,
    enable,
  }
}

/**
 * 禁用
 */
export const useDisableWarrantyCategory = () => {
  // 禁用加载
  const disableLoading = ref(false)

  /**
   * 禁用
   * @param ids - 质保类别id集合
   */
  const disable = async (ids: Array<string>) => {
    disableLoading.value = true
    const res = await updateWarrantyCategoryStatusByIds(ids, true)
    disableLoading.value = false
    return res.data
  }

  return {
    disableLoading,
    disable,
  }
}
